package com.skit.common.retrofit

import com.skit.common.bean.ActivityBean
import com.skit.common.bean.ActivityBean.TypeBean
import com.skit.common.bean.ApplyBean
import com.skit.common.bean.StatusResult
import retrofit2.Call
import retrofit2.http.*

/**
 * @author shuike [Contact me.](mailto:shuike007@gmail.com)
 * @version 1.0
 * @since 2020/5/27
 */
interface ActivityProtocol {

    @GET("v1/collection/query")
    suspend fun getUserCollectActivityList(
        @Query("uid") uid: Int,
        @Query("page") page: Int
    ): StatusResult<List<ActivityBean>>

    @GET("v1/activity/all")
    fun getActivityList(
        @Query("limit") limit: Int,
        @Query("skip") skip: Int,
        @Query("type") type: Int
    ): Call<StatusResult<List<ActivityBean>>>

    @GET("v1/activity/schedule")
    fun getActivityListByTime(
        @Query("type") type: Int,
        @Query("time") time: Long,
        @Query("page") page: Int,
    ): Call<StatusResult<List<ActivityBean>>>

    @GET("v1/activity/all")
    suspend fun getActivityListSync(
        @Query("limit") limit: Int,
        @Query("skip") skip: Int,
        @Query("type") type: Int
    ): StatusResult<List<ActivityBean>>

    @GET("v1/activity/searchByName")
    fun searchActivityByName(
        @Query("limit") limit: Int,
        @Query("skip") skip: Int,
        @Query("name") name: String
    ): Call<StatusResult<List<ActivityBean>>>

    @GET("v1/activity/info")
    fun getActivityInfo(
        @Query("id") id: Int,
        @Query("uid") uid: Int
    ): Call<StatusResult<ActivityBean>>

    @POST("v1/activity/add")
    @Headers("Content-Type:application/x-www-form-urlencoded; charset=utf-8")
    @FormUrlEncoded
    fun addActivity(
        @Field("token") token: String,
        @Field("data") jsonData: String
    ): Call<StatusResult<String>>

    @POST("v1/activity/apply")
    @Headers("Content-Type:application/x-www-form-urlencoded; charset=utf-8")
    @FormUrlEncoded
    fun apply(
        @Field("token") token: String,
        @Field("data") jsonData: String
    ): Call<StatusResult<String>>

    @POST("v1/activity/check")
    @Headers("Content-Type:application/x-www-form-urlencoded; charset=utf-8")
    @FormUrlEncoded
    fun checkApply(
        @Field("uid") uid: Int,
        @Field("aid") aid: Int,
        @Field("status") status: Int,
        @Field("checkID") checkID: Int
    ): Call<StatusResult<String>>

    @POST("v1/activity/changeStatus")
    @Headers("Content-Type:application/x-www-form-urlencoded; charset=utf-8")
    @FormUrlEncoded
    fun changeStatus(
        @Field("token") token: String,
        @Field("uid") uid: Int,
        @Field("aid") aid: Int,
        @Field("status") status: Int
    ): Call<StatusResult<String>>

    @get:GET("v1/activity/type")
    val activityType: Call<StatusResult<List<TypeBean>>>

    @GET("v1/activity/applyList")
    fun getApplyList(
        @Query("aid") aid: Int,
        @Query("type") type: String
    ): Call<StatusResult<List<ApplyBean>>>

    @POST("v1/collection/add")
    @Headers("Content-Type:application/x-www-form-urlencoded; charset=utf-8")
    @FormUrlEncoded
    fun addCollect(
        @Field("uid") uid: Int,
        @Field("aid") aid: Int,
        @Field("type") type: String,
    ): Call<StatusResult<Unit>>
}